from django.db import models
import django.utils.timezone as timezone


class AlloyPhaseDiagram(models.Model):
    """
    合金相图model，定义了合金相图相关属性
    """
    alloy_phase_diagram_id = models.AutoField(max_length=20, primary_key=True, unique=True,
                                              verbose_name='alloy_phase_diagram_id')  # 合金相图id
    alloy_name = models.CharField(
        max_length=50, null=True, blank=True, verbose_name='alloy_name')  # 合金名称
    alloy_code = models.TextField(
        null=False, blank=False, verbose_name='alloy_code')  # 合金代码
    alloy_phase_diagram = models.FileField(upload_to='alloyPhaseDiagram/alloy_phase_diagram/%Y/%m/%d/%H%M%S/', null=True, blank=True,
                                           verbose_name='alloy_phase_diagram')  # 合金相图，可查看和下载
    add_date = models.DateTimeField(default=timezone.now)  # 保存时间
    mod_date = models.DateTimeField(auto_now=True)  # 最后修改时间

    class Meta:
        db_table = 'alloy_phase_diagram'  # 内嵌类指定合金相图表表名
        # 权限设置
        default_permissions = ()
        permissions = (
            ('view_alloy', u'查看合金'),
            ('add_alloy', u'添加合金'),
            ('delete_alloy', u'删除合金'),
            ('change_alloy', u'修改合金'),
        )


# class Attachment(models.Model):
#     """
#     附件Model，存储所有的附件
#     """
#     attachment_id = models.AutoField(max_length=20, primary_key=True, unique=True,
#                                      verbose_name='attachment_id')  # 附件id
#     attachment_name = models.CharField(
#         max_length=50, null=False, blank=False, verbose_name='attachment_name')  # 附件名称
    
#     file = models.FileField(upload_to='attachments/%Y/%m/%d/%H%M%S/',
#                             null=False, blank=False, verbose_name='file')  # 文件

#     class Meta:
#         db_table = 'attachment'  # 内嵌类指定附件表表名
